#include <iostream>
#include <string.h>
#include <vector>
using std::cout;
using std::endl;
using std::vector;

/*
 * 要求此版本仅能访问堆对象
 * */

class Point{
private:
    int _x;
    int _y;

public:
    Point(int x, int y)
        :_x(x)
        ,_y(y)
    {
        printf("构造函数\n");
    }

    ~Point(){
        printf("析构函数\n");
    }

    void print(){
        printf("_x: %d, _y: %d \n", _x, _y);
    }
};

int main()
{
    Point pt0 = Point(0, 1);
    Point pt1 = Point(2, 4);
    Point pt2 = Point(8, 16);
    vector <Point> vec = {pt0, pt1, pt2};
    
    for(size_t i = 0; i < vec.size(); i++){
        vec[i].print();
    }

    for(auto & pt : vec){
        pt.print();
    }

    auto it = vec.begin();
    while(it != vec.end()){
        it->print();
        ++it;
    }

    return 0;
}

